package net.jxtz.jxtzos.authentication;

import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.config.annotation.ObjectPostProcessor;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;


/**
 * MyObjectPostProcessor
 * @author a123
 */
public class MyObjectPostProcessor implements ObjectPostProcessor<FilterSecurityInterceptor> {

    /**
     * 资源校验
     */
    private final AccessDecisionManager accessDecisionManager;

    /**
     * 资源过滤
     */
    private final FilterInvocationSecurityMetadataSource filterInvocationSecurityMetadataSource;

    public MyObjectPostProcessor(AccessDecisionManager accessDecisionManager, FilterInvocationSecurityMetadataSource filterInvocationSecurityMetadataSource){
        this.accessDecisionManager = accessDecisionManager;
        this.filterInvocationSecurityMetadataSource = filterInvocationSecurityMetadataSource;
    }

    @Override
    public <O extends FilterSecurityInterceptor> O postProcess(O o) {
        o.setAccessDecisionManager(accessDecisionManager);
        o.setSecurityMetadataSource(filterInvocationSecurityMetadataSource);
        return o;
    }
}
